package com.xuecheng.order.config;

import org.springframework.amqp.core.*;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitMQConfig {
    // 交换机配置
    @Bean("order_exchange")
    public Exchange EX_DECLARE() {
        return ExchangeBuilder.directExchange("order_exchange").durable(true).build();
    }
    //声明队列
    @Bean("order_queue")
    public Queue QUEUE_DECLARE() {
        return new Queue("order_queue",true,false,true);
    }
    // 绑定队列到交换机
    @Bean
    public Binding bind(@Qualifier("order_queue") Queue queue, @Qualifier("order_exchange") Exchange exchange) {
        return BindingBuilder.bind(queue).to(exchange).with("routing_key").noargs();
    }


}
